package com.baby.work.config;


import com.baby.work.domain.aop.Calculator;
import com.baby.work.domain.aop.CalculatorImpl;
import com.baby.work.domain.ioc.TestIoc;
import com.baby.work.domain.operator.IOperator;
import com.baby.work.domain.operator.MobileOperator;
import com.baby.work.domain.operator.TelecomOperator;
import com.baby.work.domain.operator.UnicomOperator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import java.util.ArrayList;

@Configuration
public class BeanFactory {

    @Primary
    @Bean
    public TestIoc produceTestIoc() {
        return new TestIoc("baby");
    }

    @Bean
    public MobileOperator getMO() {
        return new MobileOperator();
    }

    @Bean
    public UnicomOperator getUO() {
        return new UnicomOperator();
    }

    @Bean
    public TelecomOperator getTO() {
        return new TelecomOperator();
    }

    @Bean
    public ArrayList<IOperator> getOperators() {
        ArrayList<IOperator> operators = new ArrayList<>();
        operators.add(new MobileOperator());
        operators.add(new UnicomOperator());
        operators.add(new TelecomOperator());
        return operators;
    }

    @Bean
    public Calculator getCalculator() {
        return new CalculatorImpl();
    }

}
